﻿<?php
    function chinesesubstr($str, $start, $len) { // $str指字符串,$start指字符串的起始位置，$len指字符串长度
        $strlen = $start + $len; // 用$strlen存储字符串的总长度，即从字符串的起始位置到字符串的总长度
 $tmpstr="";
        for($i = $start; $i < $strlen;) {
            if (ord ( substr ( $str, $i, 1 ) ) > 0xa0) { // 如果字符串中首个字节的ASCII序数值大于0xa0,则表示汉字
                $tmpstr .= substr ( $str, $i, 3 ); // 每次取出三位字符赋给变量$tmpstr，即等于一个汉字
                $i=$i+3; // 变量自加3
            } else{
                $tmpstr .= substr ( $str, $i, 1 ); // 如果不是汉字，则每次取出一位字符赋给变量$tmpstr
                $i++;
            }
        }
        return $tmpstr; // 返回字符串
    }


	header("Content-Type:text/html;charset=utf-8");
	require "page.class.php";
	include '../conn/mysql.php';
	include '../check.php';
	$num=sql("frow", "list", "id", "where tjr='".$user."'");
	$page=new Page($num,20);
	$res=sql("s", "list", "*", "where tjr='".$user."' order by id desc {$page->limit}");
	echo '<div class="right_con2">
               <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr bgcolor="#f2f2f2" class="right_con2_top">
                <td width="117" height="43" class="youxia" >下单时间</td>
                <td width="70" class="youxia">订单ID </td>
                <td width="233" class="youxia">购买商品 </td>
                <td width="98" class="youxia">公众号</td>
                <td width="97" class="youxia">金额 </td>
                <td width="88" class="youxia">状态 </td>
                <td width="72" class="xia">详情</td>
              </tr>';
	if($res){
		$k=1;
		foreach ($res as $info){
			$jg=gv($info,'jg')*1;
			$fc=gv($info,'fc')*1;
			if (gv($info,'zt')==1) {
				$color='red';
			}else{
				$color='green';
			}
			if($k%2==1){
				$col="#FFFFFF";
				}else{
					$col="#FFFFCC";
					}
			echo '<tr bgcolor="'.$col.'"><td  height="36" class="youxia">'.gv($info,'time').'</td><td height="36" class="youxia">**'.substr(gv($info,'shr'),-3).substr(gv($info,'tel'),0,3).'***</td><td height="36" class="youxia">'.chinesesubstr(gv($info,'spm').gv($info,'suk'),0,34).'</td><td height="36" class="youxia">'.gv($info,'channel').'</td><td height="36" class="youxia">'.$jg.' / '.$fc.'</td><td height="36" class="youxia"><font color="'.$color.'">'.zt(gv($info,'zt')).'</font></td><td height="36" class="xia"><a href="order_detail.php?id='.gv($info,'id').'">详情</a></td></tr>';
		$k++;
		}
	}
	
	echo '</table></div>
	<div class="uc-pager">'.$page->fpage().'</div>';
